#ifndef LEVEL_H
#define LEVEL_H

#include <GL/glut.h>
#include <vector>

#include "UtilFunctions.h"

using namespace std;

class Level
{
	public:
		Level ();

		void Update ();
		bool LoadTextures();

	private:
		vector<GLuint> texture;
		
};

Level::Level()
{
	texture.resize(1);
}

void Level::Update()
{
	// Bind Texture
	glBindTexture(GL_TEXTURE_2D, texture[0]);

	// Draw ground
	glColor3f(0.0f, 1.0f, 0.0);
	glBegin(GL_QUADS);
		for (int x = 0; x < 20; x++)
		{
			for (int y = 0; y < 20; y++)
			{	
				float height = 0;
				if (x == y && x%5 == 0)
					height = 32;
				glTexCoord2f(0.0f,0.0f); glVertex3f(x*80, height, -y*80); 
				glTexCoord2f(0.0f,1.0f); glVertex3f(x*80, height, -(y+1)*80);
				glTexCoord2f(1.0f,1.0f); glVertex3f((x+1)*80, height, -(y+1)*80);
				glTexCoord2f(1.0f,0.0f); glVertex3f((x+1)*80, height, -y*80);
			}
		}
	glEnd();
}

bool Level::LoadTextures()
{
	return LoadGLTextures(texture[0], "grass.bmp",2);
}

#endif